using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using TT.Module.sysLogin;
using SfcorpDLL.ety;
using SQLHelper;

namespace SfcorpDLL.dao
{
    public class daoClient
    {
        etyBaeSystemParamter basSysParam;

        public daoClient(etyBaeSystemParamter ieyBasClassDeclare)
        {
            basSysParam = ieyBasClassDeclare;
        }

        public DataTable GetClient(etyClient inEty)
        {
            //string sql = "select CLIENT_ID,CLIENT_NAM,ENABLE_FLAG,CLIENT_CONTACT,CONTRACT_DATE_VAL_BEG,CONTRACT_DATE_VAL_END,COLLABORATE_ID,DEPT_COD,DEPT_NAM,CLIENT_CONTACT1 from C_CLIENT  " ;
            string sql = "select * from v_c_client  ";
            return basSysParam.SqlHelp.ExecuteReader(sql, inEty);
        }

        public daoResult Insert_Client(etyClient inEty)
        {//()//to_date(:CONTRACT_DATE_VAL_BEG,'yyyy-mm-dd HH24:mi:ss'),TO_DATE(:CONTRACT_DATE_VAL_END,'yyyy-mm-dd HH24:mi:ss')
            string sql = "insert into C_CLIENT(CLIENT_ID,CLIENT_NAM,ENABLE_FLAG,REC_NAM,REC_TIM,SEQ_NO,CLIENT_CONTACT,CONTRACT_DATE_VAL_BEG,CONTRACT_DATE_VAL_END,COLLABORATE_ID,CLIENT_CONTACT1,CUSTOMER_ID,FEE_WAY_ID) "
                + "values(:CLIENT_ID,:CLIENT_NAM,:ENABLE_FLAG,:REC_NAM,SYSDATE,nvl(:SEQ_NO,(select nvl(max(SEQ_NO),0)+1 from C_CLIENT)),:CLIENT_CONTACT,SYSDATE,SYSDATE,:COLLABORATE_ID,:CLIENT_CONTACT1,:CUSTOMER_ID,:FEE_WAY_ID)";
            return basSysParam.SqlHelp.ExecuteTrans(sql, inEty);
        }

        public daoResult Update_Client(etyClient inEty)
        {//CONTRACT_DATE_VAL_BEG=:CONTRACT_DATE_VAL_BEG,CONTRACT_DATE_VAL_END=:CONTRACT_DATE_VAL_END,
            string sql = "update C_CLIENT set CLIENT_ID=:CLIENT_ID,CLIENT_NAM=:CLIENT_NAM,ENABLE_FLAG=:ENABLE_FLAG,CLIENT_CONTACT=:CLIENT_CONTACT,UPDATE_NAM=:UPDATE_NAM,UPDATE_TIM=SYSDATE,LST_UPD_DATE=SYSDATE,COLLABORATE_ID=:COLLABORATE_ID,DEPT_COD=:DEPT_COD,DEPT_NAM=:DEPT_NAM,CLIENT_CONTACT1=:CLIENT_CONTACT1,SEQ_NO=:SEQ_NO,CUSTOMER_ID=:CUSTOMER_ID,FEE_WAY_ID=:FEE_WAY_ID where  ROWID =:ROW_ID ";
            return basSysParam.SqlHelp.ExecuteTrans(sql, inEty);
        }

        public daoResult Delete_Client(etyClient inEty)
        {
            string sql = "delete C_CLIENT where  ROWID =:ROW_ID ";
            return basSysParam.SqlHelp.ExecuteTrans(sql, inEty);
        }

    }
}